<!DOCTYPE html>
<html lang="en">
<head>
	<base href="${basePath}">
	<#include "common/top.html"/>
	<link type="text/css" rel="stylesheet" href="${basePath}plugins/zTree/3.5.1/zTreeStyle/zTreeStyle.css"/>
	<script type="text/javascript" src="${basePath}plugins/zTree/3.5.1/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="${basePath}plugins/zTree/3.5.1/jquery.ztree.excheck.js"></script>
</head>
<body>
<form class="layui-form"  method="post" name="deptForm" id="deptForm">
	<div class="levTable">
		<table id="simple-table" class="table table-striped table-bordered table-hover" >
			<thead>
			<tr>
				<th>上级部门</th>
				<th>部门名称</th>
				<th>部门ID</th>
				<th style="width: 100px;">操作</th>
			</tr>
			</thead>
			<tbody>
				<tr>
					<td>${dept.parentName}</td>
					<td>${dept.deptName}</td>
					<td>${dept.deptId}</td>
					<td >
						<div>
							<i class="iconfont" onclick="editDept('${dept.deptId}');" title="修改">&#xe642;</i>
							<i class="iconfont" onclick="deleteUser('${dept.deptId}');" title="删除">&#xe640;</i>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
	<#include "/common/page.html" />
</form>
</body>
<script type="text/javascript">
	//修改
	function editDept(deptId) {
		var _url = $("form:eq(0)").attr("action");
		layer.open({
			type : 2,//此处以iframe举例
			title : '部门信息编辑',
			area : [ '450px', '400px' ],
			maxmin : true,
			content : '${basePath}sysuser/dept/toDeptEdit?deptId='+deptId,
			btn : [ '保存', '关闭' ], //只是为了演示
			yes : function(index, layero) {
				var iframeWin = window[layero.find('iframe')[0]['name']];
				iframeWin.save1();
			},
			no : function(index) {
				layer.close(index);
			},
			end : function() {
				//setTimeout("self.location.reload()", 100);
				reLoadPage(_url);
			}
		});
	}

	// 删除
	function deleteUser(deptId) {

		layer.confirm('确认要删除吗？', {
			btn: ['确定', '取消']
		}, function(index, layero){
			$.ajax({
				url : '${basePath}sysuser/dept/deleteDept',
				data : {
					deptId : deptId
				},
				type : "POST",
				success : function(data) {
					if (data.status == 'success') {
						layer.alert(data.msg,function(index){
							setTimeout("self.location.reload()", 100);
						});
					} else {
						layer.alert(data.msg);
					}
				}
			});
		});
	}
</script>
</html>